/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tallerfinal.util.distributions;

import tallerfinal.util.distributions.factory.GeneratorsFactory;
import tallerfinal.util.enums.DistributionsName;

/**
 *
 * @author ricardo
 */
public class UniformGenerator extends Generator<Double> {
static {
        GeneratorsFactory.getInstance().registerProduct(DistributionsName.UNIFORME, UniformGenerator.class);
    }
    private double a, b;

    public UniformGenerator(double a, double b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public Double generate() {
        double u = generator.nextDouble();
        return (b - a) * u + a;
    }
}
